package states
{
	import org.flixel.*;
	
	/**
	 * State class for the credits screen
	 *
	 * @author Jesse Jeng
	 */
	public class CreditState extends FlxState
	{
		override public function create():void
		{
			super.create();
			
			add(Registry.epicBackground);
			Registry.epicBackground.setAll("alpha", 0.25);
			
			initBottom();
			
			var textBG:FlxSprite = new FlxSprite();
			textBG.loadGraphic(Assets.ImgCredits);
			add(textBG);
			
			MusicPlayer.play(MusicPlayer.CREDITS);
		}
		
		override public function destroy():void
		{
			Registry.epicBackground.setAll("alpha", 1.0);
			clear();
			
			super.destroy();
		}
		
		override public function update():void
		{
			super.update();
			
			if (FlxG.keys.justPressed("SPACE"))
			{
				FlxG.switchState(new MenuState());
			}
		}
		
		private function initBottom():void
		{
			var _overlayBottom:FlxSprite = new FlxSprite();
			_overlayBottom.makeGraphic(FlxG.width, 25, 0xFF000000, true);
			_overlayBottom.alpha = 0.5;
			_overlayBottom.y = FlxG.height - 25;
			add(_overlayBottom);
			
			var _creditInstructions:FlxText = new FlxText(0, 0, FlxG.width);
			_creditInstructions.font = "cooper_black";
			_creditInstructions.alignment = "center";
			_creditInstructions.size = 20;
			_creditInstructions.color = 0xFFFFFFFF;
			_creditInstructions.text = "Press SPACE to continue.";
			_creditInstructions.y = FlxG.height - _creditInstructions.height;
			add(_creditInstructions);
		}
	}
}